package org.ediba.siri.core.action.service;

import java.util.List;
import java.util.Map;

import org.ediba.siri.core.Filter;
import org.ediba.siri.core.action.domain.ActionDownload;
import org.ediba.siri.core.action.domain.ActionRequest;
import org.ediba.siri.core.action.domain.ActionUsed;
import org.ediba.siri.core.publication.domain.Publication;
import org.ediba.siri.core.user.domain.User;

public interface ActionService {

	public static final int ERROR_OK = 0;
	public static final int ERROR_LOCK = 1;
	public static final int ERROR_OWNER = 2;
	public static final int ERROR_NOT_AUTHORIZED = 3;
	public static final int ERROR_NOT_REQUESTED = 4;
	public static final int ERROR_DOWNLOADED = 5;
	public static final int ERROR_NOT_GRANTED = 6;
	public static final int ERROR_NOT_DOWNLOADED = 7;
	public static final int ERROR_REQUESTED = 8;
	public static final int ERROR_GRANTED = 9;
	
	public List<ActionRequest> requestRetrieve(Map<Filter, Object> filters, String sort, boolean dir, int start, int limit);
	abstract List<ActionRequest> requestRetrieve(String sort, boolean dir, Integer start, Integer limit);
	abstract Integer requestRetrieveCount(Map<Filter, Object> filters);
	abstract Integer requestRetrieveCount();
	
	public List<ActionDownload> downloadRetrieve(Map<Filter, Object> filters, String sort, boolean dir, int start, int limit);
	abstract List<ActionDownload> downloadRetrieve(String sort, boolean dir, Integer start, Integer limit);
	abstract Integer downloadRetrieveCount(Map<Filter, Object> filters);
	abstract Integer downloadRetrieveCount();
	
	abstract List<Publication> publicationsRetrieve(Integer idDownload);
	
	public List<ActionUsed> usedRetrieve();
	public List<ActionUsed> usedRetrieveByImage(int idImage);
	public int downloadCheck(int idImage, boolean force);
	
	public boolean canForceDownload(User user);
	public int request(int idImage, int idPublication);
	public int grantRequest(int idRequest);
	public int grant(int idImage, int idPublication, int idUser);
	public int rejectRequest(int idRequest);
	public int reject(int idImage, int idPublication, int idUser);
	public int download(int idImage, boolean force);
	public int usedDownload(int idDownload, int idPublicationNumber, int page, boolean modified);
	public int used(int idImage, int idPublicationNumber, int page, boolean modified);
	public int unusedDownload(int idDownload);
	public int unused(int idImage);
	public int finishRequest(int idRequest);
	public int finishGrant(int idGrant);
	public int finishDownload(int idDownload);

	public List<ActionRequest> pendingActionRequestCurrent();
	public List<ActionDownload> pendingActionDownloadCurrent();
/*	
	//ActionDownload
	abstract ActionDownload downloadCreate(int idImage);
	abstract ActionDownload downloadRetrieve(int id);
	abstract ActionDownload downloadUpdate(ActionDownload download);
	abstract boolean downloadDelete(int id);
	abstract List<ActionDownload> downloadRetrieve();
	abstract List<ActionDownload> downloadRetrieve(Filter filter, Object value, String sort, boolean dir, Integer start, Integer limit);
	abstract List<ActionDownload> downloadRetrieve(String sort, boolean dir, Integer start, Integer limit);
	abstract Integer downloadRetrieveCount(Filter filter, Object value);
	
	//ActionRequest
	abstract ActionRequest requestCreate(int idAction);
	abstract ActionRequest requestRetrieve(int id);
	abstract ActionRequest requestUpdate(ActionRequest request);
	abstract boolean requestDelete(int id);
	abstract List<ActionRequest> requestRetrieve();
	abstract List<ActionRequest> requestRetrieve(Filter filter, Object value, String sort, boolean dir, Integer start, Integer limit);
	abstract List<ActionRequest> requestRetrieve(String sort, boolean dir, Integer start, Integer limit);
	abstract Integer requestRetrieveCount(Filter filter, Object value);
*/	
	/*	
	//ActionGrant
	abstract ActionGrant grantCreate(int idActionRequest);
	abstract ActionGrant grantRetrieve(int id);
	abstract ActionGrant grantUpdate(ActionGrant grant);
	abstract boolean grantDelete(int id);
	abstract List<ActionGrant> grantRetrieve();

	//ActionReject
	abstract ActionReject rejectCreate(int idActionRequest);
	abstract ActionReject rejectRetrieve(int id);
	abstract ActionReject rejectUpdate(ActionReject reject);
	abstract boolean rejectDelete(int id);
	abstract List<ActionReject> rejectRetrieve();

	//ActionUnused
	abstract ActionUnused unusedCreate(int idActiondownload);
	abstract ActionUnused unusedRetrieve(int id);
	abstract ActionUnused unusedUpdate(ActionUnused unused);
	abstract boolean unusedDelete(int id);
	abstract List<ActionUnused> unusedRetrieve();

	//ActionUsed
	abstract ActionUsed usedCreate(int idPublicationNumber, int idActionDownload, int page, boolean modified);
	abstract ActionUsed usedRetrieve(int id);
	abstract ActionUsed usedUpdate(ActionUsed used);
	abstract boolean usedDelete(int id);*/

	
}
